refactor(core): migrate lang_analyzer cache from bincode to postcard#16
Merged
Merged
Conversation
Replace bincode 1.x (RUSTSEC-2025-0141 — permanently unmaintained) with postcard 1.x in the three call sites inside mlxcel-core's lang_analyzer/cache.rs. postcard 1.x is 1.0+ stable with a frozen wire format, serde-based (drop-in API), and is the embedded Rust ecosystem standard — a natural fit for an inference runtime crate. Changed files: Cargo.toml (bincode → postcard 1 alloc feature), cache.rs (bincode::deserialize → postcard::from_bytes, bincode::serialize → postcard::to_allocvec, doc comments updated), mod.rs (Bincode error variant → Postcard, module doc updated).
bincode 1.x is no longer in the dependency tree (replaced by postcard 1.x in mlxcel-core). Remove the ignore entry so cargo deny enforces the advisory going forward. The paste advisory (RUSTSEC-2024-0436) is retained — it is a separate transitive-via-tokenizers concern, unchanged by this PR.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
bincode 1.x(RUSTSEC-2025-0141, permanently unmaintained) withpostcard 1.xinmlxcel-core'slang_analyzerdisk cache[advisories.ignore]entry fromdeny.tomlnow that bincode is gone from the dep treeArchitectural decision
postcard 1.xwas chosen over the other alternatives (bitcode,rkyv,bincode 2.x) for these reasons:bitcodeis pre-1.0 and has changed wire formats between minor versionspostcard::to_allocvec(&v)?/postcard::from_bytes::<T>(&bytes)?— minimal change to the 3 call sites in one fileCache format compatibility
mlxcel-core's corrupt-detection path in
lang_analyzer/cache.rsrenames any file that fails deserialization to*.broken.<epoch>.bakbefore rebuilding from the tokenizer source. Production users with old bincode-format caches will gracefully degrade on upgrade — the postcardfrom_bytescall will fail, the corrupt-detection path fires, and the cache is rebuilt automatically. No explicit migration code is needed.What changed
src/lib/mlxcel-core/Cargo.toml:bincode = "1"→postcard = { version = "1", features = ["alloc"] }src/lib/mlxcel-core/src/lang_analyzer/cache.rs:bincode::deserialize→postcard::from_bytes,bincode::serialize→postcard::to_allocvec, doc comments updatedsrc/lib/mlxcel-core/src/lang_analyzer/mod.rs:Bincode(#[from] bincode::Error)→Postcard(#[from] postcard::Error), module doc updateddeny.toml: removedRUSTSEC-2025-0141ignore entry; paste entry retainedVerification
cargo check --lib -p mlxcel-core --no-default-features— passes cleanlycargo tree -p mlxcel-core -i bincode— returns "package not found" (bincode fully removed)cargo deny check— passes withadvisories okand RUSTSEC-2025-0141 no longer ignoredCloses #8